import 'package:hongsheng/api/SPClassApiManager.dart';
import 'package:hongsheng/app/SPClassApplicaion.dart';
import 'package:hongsheng/utils/SPClassCommonMethods.dart';
import 'package:hongsheng/utils/SPClassImageUtil.dart';
import 'package:hongsheng/utils/SPClassNavigatorUtils.dart';
import 'package:hongsheng/utils/colors.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../SPClassHomeRangkingList.dart';

class SPClassTabHotExpert extends StatefulWidget {
 String ?spProMatchType ;
 SPClassTabHotExpertState ?spProState;

 SPClassTabHotExpert(this.spProMatchType);
 @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return spProState=SPClassTabHotExpertState();
  }

}


class SPClassTabHotExpertState extends State<SPClassTabHotExpert> with TickerProviderStateMixin{
  var spProTabExpertTitles=["胜率",/*"连红"*/];
  List<SPClassHomeRangkingList> spProExpertViews=[];
  TabController ?spProTabExpertController;
  var spProTabExpertKey=["hot",/*"max_red_num"*/];

  get spProBodyParameters => null;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    spProTabExpertController=TabController(length: spProTabExpertTitles.length,vsync: this);
    spProExpertViews=spProTabExpertKey.map((key){ return SPClassHomeRangkingList(key,widget.spProMatchType); }).toList();

  }
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return  Container(
      decoration: BoxDecoration(
          color: Colors.white,
          boxShadow:[
            BoxShadow(
              offset: Offset(2,5),
              color: Color(0x0D000000),
              blurRadius:width(6,),),
            BoxShadow(
              offset: Offset(-5,1),
              color: Color(0x0D000000),
              blurRadius:width(6,),
            )
          ],
          borderRadius: BorderRadius.circular(width(7))
      ),
      margin: EdgeInsets.only(top: height(8),left: width(10),right: width(10),bottom:  height(8)),
      child: Column(
        children: <Widget>[
          Container(
            padding: EdgeInsets.only(left: width(13),right: width(7)),
            height:width(35),
            decoration: BoxDecoration(
                border: Border(bottom: BorderSide(width: 0.4,color: Colors.grey[300]!))
            ),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Container(
                  width: height(4),
                  height: height(14),
                  decoration: BoxDecoration(
                      color: Color(0xFFDE3C31),
                      borderRadius: BorderRadius.circular(100)
                  ),
                ),
                SizedBox(width: 4,),
                Text("人气专家"+
                    (SPClassApplicaion.spProDEBUG? "（测试）":""),style: TextStyle(fontWeight: FontWeight.w500,fontSize: sp(15)),),
                Expanded(child: SizedBox(),),
                /*  Container(
                  width: width(92),
                  child:TabBar(
                    labelColor: Color(0xFFE3494B),
                    labelPadding: EdgeInsets.zero,
                    unselectedLabelColor: Color(0xFF666666),
                    indicatorColor: Colors.red[500],
                    isScrollable: false,
                    indicatorSize:TabBarIndicatorSize.label,
                    labelStyle: GoogleFonts.notoSansSC(fontSize: sp(13),fontWeight: FontWeight.bold),
                    unselectedLabelStyle:  TextStyle(fontSize: sp(13)),
                    controller: spProTabExpertController,
                    tabs:spProTabExpertTitles.map((key){
                      return    Tab(text: key,);
                    }).toList() ,
                  ),
                ),*/
                Container(
                  margin: EdgeInsets.only(right: width(3),left: width(10)),
                  width: 0.4,
                  color: Colors.grey[300],
                  height: height(19),
                ),
                GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  child: Container(
                    padding: EdgeInsets.all(width(7)),
                    child: Image.asset(SPClassImageUtil.spFunGetImagePath("ic_btn_right"),
                      width: width(11),
                    ),
                  ),
                  onTap: (){
                    SPClassApplicaion.spProEventBus.fire("tab:expert");
                  },
                )


              ],
            ),
          ),
          Container(
            height: width(100),
            child: TabBarView(
              controller: spProTabExpertController,
              children: spProExpertViews,
            ),
          ),
          // !SPClassApplicaion.spProShowMenuList.contains("bcw_data")? SizedBox():Container(
          //   decoration: BoxDecoration(
          //       border: Border(top: BorderSide(width: 0.4,color: Colors.grey[300]!))
          //   ),
          //   padding: EdgeInsets.only(left: height(5),right: height(5),bottom: height(4),top:height(4)),
          //   child: Row(
          //     children: <Widget>[
          //       Expanded(
          //         child: Container(
          //           height: width(40),
          //           decoration: BoxDecoration(
          //               color: Color(0xFFFEFBED),
          //               borderRadius: BorderRadius.circular(width(5))
          //           ),
          //           child: Stack(
          //             alignment: Alignment.center,
          //             children: <Widget>[
          //               GestureDetector(
          //                 behavior: HitTestBehavior.opaque,
          //                 child: Column(
          //                   mainAxisAlignment: MainAxisAlignment.center,
          //                   crossAxisAlignment: CrossAxisAlignment.center,
          //                   children: <Widget>[
          //                     Text("AI大数据",style: TextStyle(fontSize: sp(12),fontWeight: FontWeight.bold),),
          //                     Text("AI全维度深度分析",style: TextStyle(fontSize: sp(9),color: Color(0xFF999999)),maxLines: 1,overflow: TextOverflow.ellipsis,),
          //                   ],
          //                 ),
          //                 onTap: (){
          //                   spFunGetBcwUrl("bigDataReport");
          //                 },
          //               ),
          //               Positioned(right: 2,top: 2,child: Image.asset(SPClassImageUtil.spFunGetImagePath("ic_home_fire",format: ".gif"),height: width(9),),)
          //             ],
          //           ),
          //         ),
          //       ),
          //       SizedBox(width: width(3),),
          //
          //       Expanded(
          //         child: Container(
          //           height: width(40),
          //           decoration: BoxDecoration(
          //               color: Color(0xFFEFF9FE),
          //               borderRadius: BorderRadius.circular(width(5))
          //           ),
          //           child: Stack(
          //             alignment: Alignment.center,
          //             children: <Widget>[
          //               GestureDetector(
          //                 behavior: HitTestBehavior.opaque,
          //                 child: Column(
          //                   mainAxisAlignment: MainAxisAlignment.center,
          //                   crossAxisAlignment: CrossAxisAlignment.center,
          //                   children: <Widget>[
          //                     Text("冷门分析",style: TextStyle(fontSize: sp(12),fontWeight: FontWeight.bold),),
          //                     Text("多角度分析爆冷",style: TextStyle(fontSize: sp(9),color: Color(0xFF999999)),maxLines: 1,overflow: TextOverflow.ellipsis,),
          //                   ],
          //                 ),
          //                 onTap: (){
          //                   spFunGetBcwUrl("coldJudge");
          //                 },
          //               ),
          //               Positioned(right: 2,top: 2,child: Image.asset(SPClassImageUtil.spFunGetImagePath("ic_home_new",format: ".gif"),height: width(9),),)
          //             ],
          //           ),
          //         ),
          //       ),
          //       SizedBox(width: width(3),),
          //       Expanded(
          //         child: Container(
          //           height: width(40),
          //           decoration: BoxDecoration(
          //               color: Color(0xFFF7F3FE),
          //               borderRadius: BorderRadius.circular(width(5))
          //           ),
          //           child: GestureDetector(
          //             behavior: HitTestBehavior.opaque,
          //             child: Column(
          //               mainAxisAlignment: MainAxisAlignment.center,
          //               children: <Widget>[
          //                 Text("全维预测",style: TextStyle(fontSize: sp(12),fontWeight: FontWeight.bold),),
          //                 Text("AI预测主流玩法",style: TextStyle(fontSize: sp(9),color: Color(0xFF999999)),maxLines: 1,overflow: TextOverflow.ellipsis,),
          //               ],
          //             ),
          //             onTap: ()=>{
          //               spFunGetBcwUrl("allAnalysis")
          //             },
          //           ),
          //         ),
          //       ),
          //       SizedBox(width: width(3),),
          //       Expanded(
          //         child: Container(
          //           height: width(40),
          //           decoration: BoxDecoration(
          //               color: Color(0xFFEBFCED),
          //               borderRadius: BorderRadius.circular(width(5))
          //           ),
          //           child: GestureDetector(
          //             behavior: HitTestBehavior.opaque,
          //             child: Column(
          //               mainAxisAlignment: MainAxisAlignment.center,
          //               children: <Widget>[
          //                 Text("赔率波动",style: TextStyle(fontSize: sp(12),fontWeight: FontWeight.bold),),
          //                 Text("匹配赔率波动走势",style: TextStyle(fontSize: sp(9),color: Color(0xFF999999)),maxLines: 1,overflow: TextOverflow.ellipsis,),
          //               ],
          //             ),
          //             onTap: ()=>{
          //               spFunGetBcwUrl("oddsWave")
          //             },
          //           ),
          //         ),
          //       ),
          //     ],
          //   ),
          // ),

        ],

      ),
    );
  }

  onRefresh(){
    spProExpertViews[spProTabExpertController!.index].spProState!.onFunOnRefresh();
  }

//   void spFunGetBcwUrl(String value){
//     if(spFunIsLogin(context: context)){
//       var params=SPClassApiManager.spFunGetInstance().spFunGetCommonParams();
//       params.putIfAbsent("model_type", ()=>value);
// //      SPClassNavigatorUtils.spFunPushRoute(context, SPClassWebPage( SPClassNetConfig.spFunGetBasicUrl()+"user/bcw/login?"+Transformer.urlEncodeMap(params),""));
//       SPClassNavigatorUtils.spFunPushRoute(context, WebViewPage( SPClassNetConfig.spFunGetBasicUrl()+"user/bcw/login?"+Transformer.urlEncodeMap(params),""));
//     }
//   }



}